<extend name="Console:index"/>
<block name="main">

    <!--路径导航-->
    <div>
        <ol class="breadcrumb">
            <li>电影</li>
            <li>回收站</li>
        </ol>
    </div>
    <div >
        <div style="float:left">
            <form class="form-search form-inline" method="get" action="{:U('Movie/delList')}">
                <input class="form-control" type="text" name="name"  placeholder="名字" value="{$search['name']}"/>
                <input class="form-control" type="text" name="keyword"  placeholder="关键字" value="{$search['keyword']}"/>
                <!-- <input class="form-control" type="text" name="category_id" id="" placeholder="电影分类" value="{$search['category_id']}"/> -->

                <select class="form-control" style="width: 100px" name="tv">
                    <option value=''>所有类型</option>
                    <option value='0' <eq name="search.tv" value="0">selected</eq>>电影</option>
                    <option value='1' <eq name="search.tv" value="1">selected</eq>>电视剧</option>
                </select>

                <!--   <select class="form-control" style="width: 100px" name="category_id">
                       <option value=''>所有分类</option>
                       <option value='1' <eq name="search.category_id" value="1">selected</eq>>热映电影</option>
                       <option value='2' <eq name="search.category_id" value="2">selected</eq>>即将上映</option>
                       <option value='3' <eq name="search.category_id" value="3">selected</eq>>经典电影</option>
                       <option value='4' <eq name="search.category_id" value="4">selected</eq>>海外大片</option>
                   </select>-->

                <input onclick="laydate({istime: true, format: 'YYYY-MM-DD'})" class="form-control" name="create_time" placeholder="请选择具体日期" value="{$search['create_time']}" >
                <!--<input  class="form-control"type="text" name="title" id="" placeholder="描述" value="{$search['title']}"/>-->


                <button class="form-control btn btn-warning" >搜索</button>

            </form>
        </div>


        <div style="float:right">

            <a href="{:U('Movie/add')}" class="btn btn-info">新增电影</a>
            <a href="{:U('Movie/delList')}" class="btn btn-primary">全部数据</a>
            <a href="{:U('Movie/index')}" class="btn btn-danger">退出回收站</a>
        </div>

        <div style="clear: both"></div>

        <div style="height: 10px"></div>
        <div>

            <table class="table table-bordered ">
                <tr>
                    <th>序号</th>
                    <th>id</th>
                    <th>类型</th>
                    <th>名称</th>
                    <th>标题</th>
                    <th>关键字</th>
                    <th>国家</th>
                    <th>上映年限</th>
                    <th>上映时间</th>
                    <th>评分</th>
                    <th>分类</th>
                    <th>封面图片</th>
                    <th>状态</th>
                    <th>排序</th>
                    <th>时间</th>
                    <th>操作</th>
                </tr>
                <volist name="list" id="l" key="k">
                    <tr>
                        <td><input type="checkbox" name="check"  value="{$l.id}"/> {$k}</td>

                        <td>{$l.id}</td>
                        <td>
                            <foreach name="co" item="vo">
                                <eq name="l.columns" value="$key">{$vo}</eq>
                            </foreach>
                        </td>
                        <td>{$l.name}</td>
                        <td>{$l.title}</td>
                        <td>{$l.search_keywords}</td>
                        <td>

                            <if condition="$l['country_id'] eq 1" >
                                中国
                                <elseif condition="$l['country_id'] eq 2" />
                                美国
                                <elseif condition="$l['country_id'] eq 3" />
                                日本
                                <else />
                            </if>

                        </td>
                        <td><?php echo date('Y',$l['show_time']) ?></td>
                        <td><?php echo date('Y-m-d',$l['play_time']) ?>
                            <br>
                            下架时间：<br>
                            <?php echo date('Y-m-d',$l['end_time']) ?>
                        </td>
                        <td>{$l.score}</td>
                        <td>

                            <!--{$l.category_id}-->
                            <if condition="$l['category_id'] eq 1" >
                                热映电影
                                <elseif condition="$l['category_id'] eq 2" />
                                即将上映
                                <elseif condition="$l['category_id'] eq 3" />
                                经典电影
                                <elseif condition="$l['category_id'] eq 4" />
                                海外大片
                                <else />
                            </if>

                        </td>
                        <td>
                            <a href="{$l.img_url}" target="_blank"><img style='width:100px;' src="{$l.img_url}" alt="图片无法显示"></a>

                        </td>
                        <td>

                            <eq name="l.status" value="1">
                                <a href="###" class="btn btn-success btn-sm" data-id="{$l.id}" data-type="off" >已启用</a>

                            </eq>

                            <eq name="l.status" value="2">
                                <a href="###" class="btn btn-danger btn-sm" data-id="{$l.id}" data-type="on" >已下架</a>

                            </eq>
                            <eq name="l.status" value="3">
                                已删除
                            </eq>
                        </td>
                        <td>{$l.sort}</td>
                        <!--<td>-->
                        <!--<eq name="l.status" value="1">启用</eq>-->
                        <!--<eq name="l.status" value="2"><span style="color: red">下架</span></eq>-->
                        <!--</td>-->
                        <td>创建时间:<br><?php echo date('Y-m-d H:i:s',$l['create_time']); ?><br>
                            最近修改:<br><?php echo date('Y-m-d H:i:s',$l['last_update_time']); ?>
                        </td>
                        <td>
                            <a href="{:U('Movie/edit',array('id'=>$l['id']))}" class="btn btn-warning">编辑</a>
                           <!-- <a href="{:U('Movie/editPicture',array('id'=>$l['id']))}" class="btn btn-warning">更换封面图片</a>-->
                        </td>
                    </tr>
                </volist>

                <tr>
                    <td><input type="checkbox" name="" id="allChecked"/>ALL</td>
                    <td colspan="13" >
                        <div >
                            <a href="#" class="btn btn-warning btn-sm" id="btn_on">启用</a>
                            <a href="#" class="btn btn-danger btn-sm" id="btn_off">下架</a>
                        </div>

                    </td>
                </tr>

            </table>
        </div>
        <div class="text-center">
            {$page}
        </div>
    </div>

    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script>
        $(function(){
            //选择了的数据集合
            function allchecked()
            {
                var checked = '';
                $("input[name='check']:checked").each(function () {
                    checked += $(this).prop('value') + ',';
                });
                return checked;
            }

            //全选/全不选
            $('#allChecked').click(function(){
                if ($("#allChecked").prop("checked")) {
                    $(":checkbox").prop("checked", true);
                } else {
                    $(":checkbox").prop("checked", false);
                }
            });

            //更改状态的函

            function alter(type,ids)
            {
                var t = type;
                var idlsit;
                if(ids){
                    idlist = ids;
                }else{
                    idlist = allchecked();
                }

                $.post('{:U("Movie/alter")}',{'idlist':idlist,'type':t},function(data){
                    alert(data.mes);
                    window.location.reload();
                });
            }


            //启用
            $('#btn_on').click(function(){if(confirm('你确定要对进行  "启用"  操作吗?')) alter('on');});
            //下架
            $('#btn_off').click(function(){if(confirm('你确定要对进行  "下架"  操作吗?')) alter('off');});
            $('#btn_del').click(function(){if(confirm('你确定要对进行  "删除"  操作吗?')) alter('del');});

            $("[href='###']").click(function(){
                var id = $(this).attr('data-id');
                var type = $(this).attr('data-type');
                var strType;
                if( type =='on' ){
                    strType = '启用';
                }
                if( type == 'off'){
                    strType = '下架';
                }
                if( type == 'del'){
                    strType = '删除';
                }

                if(confirm('你确定要对进行  '+strType+'  操作吗?')){
                    alter(type,id);
                }

            })

        });


    </script>

</block>